import request from "@/api/request.ts";


/**
 * 获取角色列表
 * @param params
 */
export function getRoleListApi(params: object){
    return request({
        url: 'role',
        method: 'get',
        params
    })
}

/**
* 新增角色
* @param data
*/
export function addRoleApi(data: object){
    return request({
        url: 'role',
        method: 'post',
        data: data
    })
}

// 根据ID获取角色信息
export function getRoleApi(id: number) {
    return request({
        url: `role/detail/${id}`,
        method: 'get',
    })
}

/**
 * 编辑角色
 * @param data
 */
export function editRoleApi(data: object){
    return request({
        url: 'role',
        method: 'put',
        data: data
    })
}

export function delRoleApi(id: number) {
    return request({
        url: `role/${id}`,
        method: 'delete'
    })
}

export function updateIsAdminByIdApi(id: number,isAdmin: number) {
    return request({
        url: `role/${id}/${isAdmin}`,
        method: 'patch'
    })
}